package com.wc.alorithm_blue_bridge._搜索与图论.作物杂交;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.*;

/**
 * @Author congge
 * @Date 2023/10/11 15:29
 * @description r
 * https://www.lanqiao.cn/problems/506/learning/?page=2&first_category_id=1&sort=students_count&second_category_id=3
 */
public class Main {
    public static void main(String[] args) {
        Input sc = new Input();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        int target = sc.nextInt();

        int[] grainTime = new int[n + 1];

        for (int i = 1; i <= n; i++) {
            grainTime[i] = sc.nextInt();
        }

        HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();

        int[] needTime = new int[n + 1];

        /**
         * 初始填充为最大时间
         */
        Arrays.fill(needTime, Integer.MAX_VALUE);
        /**
         * 键入初始种子
         */
        for (int i = 0; i < m; i++) {
            int grainId = sc.nextInt();
            needTime[grainId] = 0;
        }

        for (int i = 0; i < k; i++) {
            int combination1 = sc.nextInt();
            int combination2 = sc.nextInt();
            int grainId = sc.nextInt();
            ArrayList<Integer> combinations;
            if (map.containsKey(grainId)) {
                combinations = map.get(grainId);
            } else {
                combinations = new ArrayList<>();
                map.put(grainId, combinations);
            }
            combinations.add(combination1);
            combinations.add(combination2);
        }

        Main main = new Main();
        System.out.println(main.deepScan(grainTime, needTime, target, map));
    }

    /**
     * dp
     *
     * @param grainTime 种植时间
     * @param needTime  获得种子需要的时间
     * @param target    目标种子
     * @param map       合成每一种种子的方法
     * @return
     */
    public int deepScan(int[] grainTime, int[] needTime, int target, HashMap<Integer, ArrayList<Integer>> map) {
        if (needTime[target] != Integer.MAX_VALUE) {
            return needTime[target];
        }

        ArrayList<Integer> combinations = map.get(target);

        int size = combinations.size();
        int minNeedTime = Integer.MAX_VALUE;

        for (int i = 0; i < size; i += 2) {
            int combination1 = combinations.get(i);
            int combination2 = combinations.get(i + 1);
            /**
             * 需要的时间为当前需要两种作物的最长时间
             */
            int curNeedTime = Math.max(deepScan(grainTime, needTime, combination1, map),
                    deepScan(grainTime, needTime, combination2, map));

            minNeedTime = Math.min(minNeedTime, curNeedTime + Math.max(grainTime[combination1], grainTime[combination2]));
//            System.out.println(combination1 + " " + combination2 + " " + target + " " + minNeedTime);
        }
        needTime[target] = minNeedTime;
        return minNeedTime;
    }

    static class Input {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (int) in.nval;
        }
    }
}
